package dapps.entity.document;


import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springside.modules.utils.DateUtils;

import dapps.entity.IdEntity;


@Entity
// 表名与类名不相同时重新定义表名.
@Table(name = "attachment")
// 默认的缓存策略.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Attachment extends IdEntity implements Serializable  {

	private static final long serialVersionUID = 3039880880168719710L;

    private String FileName;
    private String ContentType;
	private String path;
	private Document doc;
	
	@Column(insertable = true, updatable = false)
	private Date insertDate = DateUtils.getCurrentDateTime();

	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@JoinColumn(name = "document_id")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Document getDoc() {
		return doc;
	}

	public void setDoc(Document doc) {
		this.doc= doc;
	}

	public Date getInsertDate() {
		return insertDate;
	}

	public void setInsertDate(Date insertDate) {
		this.insertDate = insertDate;
	}


	public String getFileName() {
		return FileName;
	}


	public void setFileName(String fileName) {
		FileName = fileName;
	}


	public String getContentType() {
		return ContentType;
	}


	public void setContentType(String contentType) {
		ContentType = contentType;
	}


	public String getPath() {
		return path;
	}


	public void setPath(String path) {
		this.path = path;
	}


	
}